//
//  JayIAPHelper.h
//  ent
//
//  Created by Coffee on 15-5-28.
//  Copyright (c) 2015年 ND. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "StoreKit/StoreKit.h"

/**
 *  获取IAP购买产品列表成功通知
 */
#define kProductsLoadedNotification         @"ProductsLoaded"
/**
 *  IAP购买产品成功通知
 */
#define kProductPurchasedNotification       @"ProductPurchased"
/**
 *  IAP购买产品失败通知
 */
#define kProductPurchaseFailedNotification  @"ProductPurchaseFailed"

@interface JayIAPHelper : NSObject<SKProductsRequestDelegate, SKPaymentTransactionObserver> {
    NSSet * _productIdentifiers;
    NSArray * _products;
    NSMutableSet * _purchasedProducts;
    SKProductsRequest * _request;
}

@property (retain) NSSet *productIdentifiers;
@property (retain) NSArray * products;
@property (retain) NSMutableSet *purchasedProducts;
@property (retain) SKProductsRequest *request;

- (void)requestProducts;
- (id)initWithProductIdentifiers:(NSSet *)productIdentifiers;
/**
 *  通过产品标示符购买
 */
- (void)buyProductIdentifier:(NSString *)productIdentifier;
- (void)buyProductIdentifier:(NSString *)productIdentifier quantity:(NSInteger)quantity;
/**
 *  通过产品对象购买
 */
- (void)buyProduct:(SKProduct *)product;
- (void)buyProduct:(SKProduct *)product quantity:(NSInteger)quantity;
/**
 *  传到服务端的本次购买参数
 *
 *  @param params 购买成功返回参数
 */
- (void)sendTransaction:(SKPaymentTransaction *)transaction toServerWithParams:(NSDictionary*)params;

- (void)successNotifyServerAfterBuyProduct:(SKPaymentTransaction *)transaction;
@end
